home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8502 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: cdshub.cdc.com!usenet
  2. From: Dave Misch <dmisch@dtrhp01.dtr.cdc.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Fortran to C conversion help?
  5. Date: Mon, 04 Mar 1996 13:56:17 -0500
  6. Organization: Control Data Corporation
  7. Message-ID: <313B3CD1.540F@dtrhp01.dtr.cdc.com>
  8. References: <4hf04k$ogs@pipe3.nyc.pipeline.com>
  9. NNTP-Posting-Host: dtrhp01.dtr.cdc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.07 9000/735)
  14.  
  15. Doug Kolmar wrote:
  16. > Hello folks,
  17. > I'm sort of a weekend C programmer so perhaps I've missed something, but
  18. > I'm trying to convert a function in FORTRAN to C.
  19. > Attached is the FORTRAN code followed by the C code that I've written. The
  20. > C program will compile and run, but does not yield the correct output. I.E.
  21. > integers in the range 0 to 31.
  22. > Except for the differences in the range of the RAND functions, I know
  23. > nothing about FORTRAN, so am I missing something implicit in the code? Any
  24. > help would be greatly appreciated.
  25. > Doug Kolmar
  26. > dkmar@panix.com
  27.  
  28.  
  29. For starters here are some ideas....
  30.  
  31. k and new are probably not floats (use int)
  32.  
  33. don't change the logic of the code - keep the gotos, get rid of the
  34. while loop.
  35. (if it aint broke don't fix it). All of that fortran has a C workalike.
  36.  
  37. Make you main function call the C function - dont stick the function in
  38. the main.
  39.  
  40. Don't seed the random every time - seed it only once.
  41.  
  42.  
  43. Good Luck
  44.